<%@page import="RssEasy.Core.Encrypt"%>
<%@page import="RssEasy.Core.CookieHelper"%>
<%@page import="Model.User.UserList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    CookieHelper cookie = new CookieHelper(request, response);
    UserList user = new UserList(pageContext);
    UserList editPwd = new UserList(pageContext);
    user.request();
    String account = cookie.Get("account");
    String myid = cookie.Get("myid");
    //修改联系人
    if (user.get("type").equals("lxr")) {
        user.remove("type");
        user.update().where("myid=?", myid).submit();
        out.print("1");
    }
    //修改手机号
    if (user.get("type").equals("sjh")) {
        if (Encrypt.Md532(user.get("yzm")).equals(cookie.Get("key"))) {
            String password = Encrypt.Md532(account + user.get("pwd"));
            if (user.select("pwd").where("myid=? and pwd=?", myid, password).get_first_rows()) {
                user.remove("yzm");
                user.remove("pwd");
                user.remove("type");
                user.update().where("myid=? and pwd=?", myid, password).submit();
                out.print("1");
            } else {
                out.print("2");
            }
        } else {
            out.print("3");
        }
    }
    //修改邮箱
    if (user.get("type").equals("yxh")) {
        if (Encrypt.Md532(user.get("yzm")).equals(cookie.Get("key"))) {
            String password = Encrypt.Md532(account + user.get("pwd"));
            if (user.select("pwd").where("myid=? and pwd=?", myid, password).get_first_rows()) {
                user.remove("yzm");
                user.remove("pwd");
                user.remove("type");
                user.update().where("myid=? and pwd=?", myid, password).submit();
                out.print("1");
            } else {
                out.print("4");
            }
        } else {
            out.print("3");
        }
    }
    
    if (user.get("type").equals("mm")) {
        String oldPwd = user.get("oldPwd");
        String newPwd = user.get("newPwd");
        String ackPwd = user.get("pwd");
        if (newPwd.equals(ackPwd)) {
            String password = Encrypt.Md532(account + oldPwd);
            String pwd = Encrypt.Md532(account + ackPwd);
            if (user.select("pwd").where("myid=? and pwd=?", myid, password).get_first_rows()) {
                user.remove("oldPwd");
                user.remove("newPwd");
                user.remove("type");
                user.remove("pwd");
                user.keyvalue("pwd", pwd);
                user.update().where("myid=?", myid).submit();
                out.print("1");
            } else {
                out.print("5");
            }
        } else {
            out.print("6");
        }
    }
    
    if (user.get("type").equals("zzh")) {
        user.remove("type");
        if (user.select("account").where("account=?", user.get("account")).get_first_rows()) {
            out.print("7");
        } else {
            String passwrod = Encrypt.Md532(user.get("account") + user.get("pwd"));
            user.keyvalue("parentmyid", myid).keyvalue("pwd", passwrod);
            user.timestamp();
            user.append().submit();
            out.print("8");
        }
    }
    
%>